package com.guilin.mapper;

import java.util.List;
import com.guilin.domain.Alumni;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 校友信息Mapper接口
 * 
 * @author xiaoqi
 * @date 2025-06-07
 */
public interface AlumniMapper 
{
    /**
     * 查询校友信息
     * 
     * @param id 校友信息主键
     * @return 校友信息
     */
    public Alumni selectAlumniById(Long id);

    /**
     * 查询校友信息列表
     * 
     * @param alumni 校友信息
     * @return 校友信息集合
     */
    public List<Alumni> selectAlumniList(Alumni alumni);

    /**
     * 新增校友信息
     * 
     * @param alumni 校友信息
     * @return 结果
     */
    public int insertAlumni(Alumni alumni);

    /**
     * 修改校友信息
     * 
     * @param alumni 校友信息
     * @return 结果
     */
    public int updateAlumni(Alumni alumni);

    /**
     * 删除校友信息
     * 
     * @param id 校友信息主键
     * @return 结果
     */
    public int deleteAlumniById(Long id);

    /**
     * 批量删除校友信息
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAlumniByIds(Long[] ids);

    /**
     * 校验用户名是否唯一
     * @param username
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where username = #{username}")
    public Alumni checkUsernameUnique(String username);

    /**
     * 校验手机号码是否唯一
     * @param phone
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where phone = #{phone}")
    public Alumni checkPhoneUnique(String phone);

    /**
     * 校验邮箱是否唯一
     * @param email
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where email = #{email}")
    public Alumni checkEmailUnique(String email);


    /**
     * 根据用户名查询校友信息
     * @param username
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where username = #{username}")
    Alumni selectAlumniByUsername(String username);

    /**
     * 根据手机号查询校友信息
     * @param phone
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where phone = #{phone}")
    Alumni selectAlumniByPhone(String phone);

    /**
     * 根据邮箱查询校友信息
     * @param email
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where email = #{email}")
    Alumni selectAlumniByEmail(String email);

    /**
     * 修改密码
     * @param alumniId
     * @param newPassword
     * @return
     */
    @Update("update alumni set password = #{newPassword} where id = #{id}")
    int updateAlumniPwd(@Param("id") Long alumniId, @Param("newPassword") String newPassword);

    /**
     * 根据用户ID查询校友信息
     * @param userId
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where sys_user_id = #{userId}")
    Alumni selectUserId(Long userId);

    /**
     * 根据用户名查询校友信息
     * @param username
     * @return
     */
    @Select("select id, sys_user_id, avatar_url, username, password, alumni_role, sex, account_status, last_login_time, real_name, graduation_year," +
            "graduation_school, major, phone, email, current_address, company, position, create_time, update_time " +
            "from alumni where username = #{username}")
    Alumni selectAlumniByUserName(String username);
}
